limsEquiptRepair.detailPage = {

    getBtnToolbar : function() {
        var _this = this;

        if('edit' == _this.param.page){
            return {
                type : 'btnToolbar',
                items : [ {
                    type : 'button',
                    text : 'GIKAM.WORKFLOW.BUTTON.SUBMIT',
                    icon : 'submit',
                    onClick : function() {
                        var selections = [];
                        selections.push({id: _this.param.id});

                        Gikam.create('workflow').submit({
                            data: selections,
                            pageObject: limsEquiptRepair
                        }).done(function () {
                            workspace.window.goBack();
                        });
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.BUTTON.BACK',
                    icon : 'back',
                    onClick : function() {
                        workspace.window.goBack();
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.BUTTON.VIEWAUDIT',
                    icon : 'view-audit',
                    onClick : function() {
                        Gikam.viewAudit('T_LIMS_EQUIPT_REPAIR', _this.param.id);
                    }
                } ]
            }
        } else if ('audit' == _this.param.page || 'implement' == _this.param.page || 'affirm' == _this.param.page){
            return {
                type : 'btnToolbar',
                items : [ {
                    type : 'button',
                    text : 'GIKAM.WORKFLOW.BUTTON.PASS',
                    icon : 'pass',
                    onClick : function() {
                        var selections = [];
                        selections.push({id: _this.param.id});

                        Gikam.create('workflow').pass({
                            data: selections,
                            pageObject: limsEquiptRepair
                        }).done(function () {
                            workspace.window.goBack();
                        });
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.WORKFLOW.BUTTON.REJECT',
                    icon : 'reject',
                    onClick : function() {
                        var selections = [];
                        selections.push({id: _this.param.id});

                        Gikam.create('workflow').reject({
                            data: selections,
                            pageObject: limsEquiptRepair
                        }).done(function () {
                            workspace.window.goBack();
                        });
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.BUTTON.BACK',
                    icon : 'back',
                    onClick : function() {
                        workspace.window.goBack();
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.BUTTON.VIEWAUDIT',
                    icon : 'view-audit',
                    onClick : function() {
                        Gikam.viewAudit('T_LIMS_EQUIPT_REPAIR', _this.param.id);
                    }
                } ]
            }
        } else {
            return {
                type : 'btnToolbar',
                items : [ {
                    type : 'button',
                    text : 'GIKAM.BUTTON.BACK',
                    icon : 'back',
                    onClick : function() {
                        workspace.window.goBack();
                    }
                }, {
                    type : 'button',
                    text : 'GIKAM.BUTTON.VIEWAUDIT',
                    icon : 'view-audit',
                    onClick : function() {
                        Gikam.viewAudit('T_LIMS_EQUIPT_REPAIR', _this.param.id);
                    }
                } ]
            }
        }

    },

    getBaseInfoTab : function() {
        var _this = this;
        return {
            type : 'tab',
            panels : [ {
                title : 'BASEMODULE.TRM.EQUIPT.REPAIRS.TAB.BASE_INFO',
                items : [ {
                    type : 'form',
                    url : _this.getCompUrl('baseInfoForm'),
                    service : 'limsEquiptRepairServiceImpl',
                    dbTable : 'T_LIMS_EQUIPT_REPAIR',
                    id : 'lims-equipt-repair-detail-base-info-form',
                    panels : limsEquiptRepair.getDetailPanels(_this.param.page),
                } ]
            } ]
        }
    },

    urlManager : {
        baseInfoForm : limsEquiptRepair.baseUrl + '/{id}',
    },

    getCompUrl : function(name) {
        if (Gikam.isEmpty(this.param.id)) {
            return '';
        }
        return Gikam.printf(this.urlManager[name], {
            id : this.param.id
        });
    },

    createPage : function() {
        Gikam.create('layout', {
            center : {
                items : [ this.getBtnToolbar(), this.getBaseInfoTab() ]
            },
            renderTo : workspace.window.$dom
        });
        return this;
    },

    init : function(param) {
        this.param = param;
        this.createPage();
    }
}
